package com.secret.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.secret.entity.User;
import com.secret.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * User
 *
 * @author: x.xu
 * 2023-02-24 17:05
 **/
@RestController
public class UserController {
    private final static Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    UserService userService;
    // 模糊查询用户
    @RequestMapping("user")
    @ResponseBody
    public String user(String name) {
        logger.info("name: {}", name);
        logger.debug("hello ----------");
        List<User> users =  userService.getUser(name);
        logger.info(" users : {}", JSONUtils.toJSONString(users));
        logger.debug("users :  ---{}-----",JSONUtils.toJSONString(users));
        return "index";
    }
}
